<?php
require('db.php');

$schooljaar = $_GET['schooljaar'];

$result = mysql_query("SELECT v.id, v.naam, v.omschrijving FROM vak v JOIN (SELECT vk.vakID FROM vakkenperklas vk JOIN (SELECT klasID FROM klasperschooljaar WHERE schooljaarID=(SELECT id FROM schooljaar WHERE kort='$schooljaar') AND leerlingID =1)k on (vk.klasID=k.klasID))z ON ( v.id = z.vakID )") or die (mysql_error());

$data = array();

while ($row = mysql_fetch_object($result)) {
    $data [] = $row;
}

echo json_encode($data);
?>